package main

import (
	"context"
	"github.com/apenella/go-ansible/pkg/execute"
	"github.com/apenella/go-ansible/pkg/execute/measure"
	"github.com/apenella/go-ansible/pkg/options"
	"github.com/apenella/go-ansible/pkg/playbook"
)

func main() {
	ansiblePlaybookConnectionOptions := &options.AnsibleConnectionOptions{
		AskPass:       false,
		Connection:    "local",
		PrivateKey:    "",
		SCPExtraArgs:  "",
		SFTPExtraArgs: "",
		SSHCommonArgs: "",
		SSHExtraArgs:  "",
		Timeout:       0,
		User:          "",
	}

	ansiblePlatbookOptions := &playbook.AnsiblePlaybookOptions{
		AskVaultPassword:  false,
		Check:             false,
		Diff:              false,
		ExtraVars:         nil,
		ExtraVarsFile:     nil,
		FlushCache:        false,
		ForceHandlers:     false,
		Forks:             "",
		Inventory:         "127.0.0.1",
		Limit:             "",
		ListHosts:         false,
		ListTags:          false,
		ListTasks:         false,
		ModulePath:        "",
		SkipTags:          "",
		StartAtTask:       "",
		Step:              false,
		SyntaxCheck:       false,
		Tags:              "",
		VaultID:           "",
		VaultPasswordFile: "",
		Verbose:           false,
		Version:           false,
	}

	executorTimeMeasurement := measure.NewExecutorTimeMeasurement(
		execute.NewDefaultExecute(
			execute.WithEnvVar("ANSIBLE_FORCE_COLOR", "true"),
		),
		measure.WithShowDuration())

	playbook := &playbook.AnsiblePlaybookCmd{
		Exec:              executorTimeMeasurement,
		Playbooks:         []string{"site.yml"},
		Options:           ansiblePlatbookOptions,
		ConnectionOptions: ansiblePlaybookConnectionOptions,
		StdoutCallback:    "",
	}

	err := playbook.Run(context.TODO())
	if err != nil {
		panic(err)
	}
}
